<?php 
	require ('../api/config.php');
    $fid = $_GET['fid'];
    $validWidPattern = '/^\d+$/';
    if (!preg_match($validWidPattern, $fid) and $fid!=NULL)  {
    	echo '<script><script> alert("非法请求，GET数据错误！"); window.location.href="../";</script>';  
		exit();
    } 
    
    if (!$fid) {echo '<script> alert("未查询到参数！"); 
            window.location.href="../index.php?fid='.$fid.'"</script>';exit();}

 	if($username==NULL){echo '<script>alert("请先登陆账号！"); 
 	window.location.href="../login.php?fid='.$fid.'"</script>';exit();
 	}
	
    $time=date("Y-m-d h:i:s");
    
    $sql = mysqli_query($conn,"SELECT f.title,f.time,f.msg,f.stoptime,f.list,f.pax,f.class,u.username,u.stat  FROM gather f JOIN users u ON f.uid=u.uid WHERE f.fid LIKE ".$fid);
    $row = mysqli_fetch_array($sql);
    if(!$row){
     	echo '<script>alert("无法查询到收集表数据，收集表不存在或者已被删除！");window.opener=null;window.close();</script>';
     	exit();
 	}
    $name = $row['title'];
    $time = $row['time'];
    $cause = $row['msg'];
    $stoptime = $row['stoptime'];
    $list = $row['list'];
    $pax = $row['pax'];
    $user = $row['username'];
    $stat = $row['stat'];
    $class = $row['class'];
    
    $sql = mysqli_query($conn,"SELECT stat FROM users WHERE username LIKE '$username' ");
    $cstats = mysqli_fetch_array($sql);
    $cstat = $cstats['stat'];
 	if($cstat=='6' or $username==$user){}
 	else{ echo '<script>alert("非收集表创作者，无法编辑或修改");
     	    window.opener=null;window.close();</script>';
     	exit();
 	}
    
    if($class=='名单示例'){
		$not_list = '';
        $sql = "SELECT username FROM `namelist`";
        mysqli_query($conn,$sql);
        $result = $conn->query($sql);
        if ($result->num_rows > 0) {// 输出数据
            while($row = $result->fetch_assoc()) {
                $us=$row['username'];
                if (strpos($list, $us) === false) {
                    $not_list = $not_list.' '.$us;
                }
            }
        }
    }
?>


<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
	<meta name="Robots" content="All" />
	<meta http-equiv="Pragma" content="no-cache">
	<meta http-equiv="windows-Target" content="_top" />
	<meta name="description" content='<?php echo $name; ?>' />
	<meta http-equiv='content-language' content='zh-CN'>
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="../style/css/index.css">
	<link rel="stylesheet" type="text/css" href="../style/css/admin.css"/>
    <title>后台管理 | <?php echo $name; ?></title>
</head>
<style type="text/css">
	#inputname #msgsz{min-height: 150px;font-size:15px;min-width:85%;}
	#tj > input{
		width: 100%;
		height: 45px;
		border-radius: 5px;
		border: none;
		color: #fff;
		font-size: 15px;
		margin-top: 10px;
	}
	.tijiao{padding-top: 10px;}
	#go1{background-color: rgba(30,144,255,0.65);}
	#go2{background-color: rgba(40,205,50,0.65);}
	#go3{background-color: rgba(220,20,60,0.65);}
	#go4{background-color: rgba(255,150,0,0.65);}
	#go5{background-color: rgba(50,200,200,0.65);}
	#sum2 > #tzmsg {
        color: #005;
        min-height: 20px;
        padding: 0px 15px;
        padding-bottom: 15px;
        text-align: left;
        word-break: normal;
        word-wrap: break-word;
        word-break: break-all;
        text-indent: 1em;
        font-size: 14px;
    }
    #bottom{margin-top:35px;}
</style>
<body>
    <div id="app">
        <div id="top">
            <div id="title"><h1 id="titles"><?php echo $name; ?></h1></div>
            <div id="list">
                <div id="list_tb"><img src="../style/image/gd.png" alt="下拉列表"></div>
                <div class="list"><ul>
                    <li id="list_li"><a href="new.php" target="_blank">新建收集表</a></li>
                    <li id="list_li"><a href="new.php?fid=<?php echo $fid; ?>" target="_blank">修改收集表</a></li>
                    <li id="list_li"><a href="all.html?fid=<?php echo $fid; ?>" target="_blank">查看收集总图</a></li>
                    <li id="list_li"><a href="zip.php?fid=<?php echo $fid; ?>" target="_blank">打包成压缩包下载</a></li>
                    <li id="list_li"><a href="list.html" target="_blank">历史收集列表</a></li>
                </div>
            </div>
        </div>
    
        <div id="msg">
			
			<div id="sum2" class="xingming">
                <div id="sum3">
                    <span id="sumts"><img src="../style/image/sum.png" alt="rq"> 提交人员统计</span>
                    <span id="gosum">当前已提交<b v-text="pax"><?php echo $pax; ?></b>份 | <?php echo $class; ?><t id="clas"></t></span>
                </div>
                <span id="inputname">
        		    <textarea  type="text" id="msgsz" wrap="virtual"  rows="" cols="" required placeholder="暂无提交数据！"><?php echo $list; ?></textarea>
        		</span>
            </div>
			
			<?php
    		if($class=="名单示例" and $not_list!=NULL){
    			echo '
    			    <div id="sum2" class="xingming">
        			    <div id="sum3">
        			        <span id="xmts"><img src="../style/image/ts.png" alt="提示"> 未提交人员</span>
        			    </div>
        			    <span id="inputname">
        			        
        			        <textarea  type="text" id="msgsz" wrap="virtual"  rows="" cols="" required placeholder="已全部提交！">'.$not_list.'</textarea>
        			    </span>
        			</div>
    			
    			';}
    		    else{
    		       echo '
    			    <div id="sum2" class="xingming">
        			    <div id="sum3"><span id="xmts"><img src="../style/image/ts.png" alt="提示"> 未提交人员</span>
        			    </div>
        			    <p id="tzmsg">全部已收集完整！（注:您正在使用通用模式，无法查看未提交人员！如需查看请将名单导入到数据表namelist中）</p>
        			</div>
        			';
    		    }
    		?>
            <div class="tijiao">
                <span id="tj">
                    <input type="submit" id="go1" class="tj1" value="修改收集表参数" onclick="go1()"/>
				    <input type="submit" id="go2" class="tj2" value="查看收集的图片" onclick="go2()"/>
					<input type="submit" id="go3" class="tj3" value="打包成压缩包下载" onclick="go3()"/>
					<input type="submit" id="go4" class="tj4" value="新建图片收集表" onclick="go4()"/>
					<input type="submit" id="go5" class="tj5" value="查看历史收集表" onclick="go5()"/>
					<?php
					if($cstat=='6' or $username=='admin')
					echo '<input type="submit" id="go1" class="tj1" value="管理员用户管理" onclick="go6()"/>';
					?>
				</span>
            </div>
        </div>
    
        <div id="bottom">
            Opyright © 2024 TOP图片收集管理系统 All Rights Reservedby.
        </div>
    </div>
</body>
<script type="text/javascript">
	function go1(){window.location.href="./new.php?fid=<?php echo $fid; ?>";	}
	function go2(){window.location.href="./all.html?fid=<?php echo $fid; ?>";	}
	function go3(){window.location.href="./zip.php?fid=<?php echo $fid; ?>";	}
	function go4(){window.location.href="./new.php";	}
	function go5(){window.location.href="./list.html";	}
	function go6(){window.location.href="./user.php";	}
</script>
</html>